import e from "./view_ctrl";
import t from "./event_center";
import n from "./event";
import Cubic from "./cubic";

export default class SectionCell extends e {
  constructor(e?) {
    super(e);
    if (arguments.length > 0) {
      this.initWithView(e);
    }
  }
  motionBox = null;
  kvMotion = null;
  motionLoading = !1;
  onViewControllerPrepared() {
    let e = this;
    e.motionBox = e.view().subViewByName("motion_box");
  }
  onViewAddToStage() {
    let e = this;
    e.prepared && e.motionBox != null && e.kvMotion == null && e.loadKVMotion();
  }
  loadKVMotion() {
    let e = this;
    if (e.motionLoading == 0) {
      e.motionLoading = !0;
      let r = e.createKVMotion();
      r != null &&
        (t.addListener(r, e, n.PREPARED, e.onKVMotionPrepared), r.initialize());
    }
  }
  onKVMotionPrepared(e) {
    let t = this;
    (t.kvMotion = e.target),
      t.motionBox.empty(),
      t.motionBox.addSubView(t.kvMotion.view()),
      t.view().stage() != null
        ? (t.kvMotion.view().alpha(0),
          t.kvMotion.view().animate(
            0.3,
            {
              alpha: 1,
            },
            Cubic.easeInOut,
            null,
            function () {
              t.motionBox.bgColor(null);
            }
          ))
        : t.motionBox.bgColor(null);
  }
  createKVMotion() {
    return null;
  }
}
